<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <base href="<%=basePath%>">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <title>Title</title>
    <script src="js/jquery-1.8.0.js"></script>
    <link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
    <script>
        $(function(){
            $("#ch_checkall,#top_ch_checkall").click(function(){
                if(this.checked){
                    $("input[name=ck_id]").attr("checked","checked");
                }else{
                    $("input[name=ck_id]").removeAttr("checked");
                }
            });

            $("table tr").mouseover(function(){
                $(this).css("background","#D3EAEF");
                $(this).siblings().css("background","white");
            });
        });

        $(function () {
            $("#but1").click(function () {
                window.location.href="AdminServlet?flag=manager&pageIndex=1";
            });
            $("#but2").click(function () {
                window.location.href="AdminServlet?flag=manager&pageIndex="+${page.pageIndex-1};
            });
            $("#but3").click(function () {
                window.location.href="AdminServlet?flag=manager&pageIndex="+${page.pageIndex+1};
            });
            $("#but4").click(function () {
                window.location.href="AdminServlet?flag=manager&pageIndex="+${page.pageCount };
            });
        });
        $(function () {
           $("#duoxuan").click(function () {
               var xuanze=document.getElementsByName("ck_id");
               var st=document.getElementsByName("st");
               var idlist="";
               for(var i=0;i<xuanze.length;i++){

                   if(xuanze[i].checked==true){
                       if(st[i].innerText!="正常"){
                           alert("非正常状态不可选");
                           return false;
                       }
                       idlist=idlist+xuanze[i].id+" ";
                   }
               }
               window.location.href="AdminServlet?flag=duoshan&id="+idlist+"&pageIndex="+${page.pageIndex};
           });
        });

    </script>

</head>
<body>
<div class ="div_title">
    <div class="div_titlename"> <img src="images/san_jiao.gif" ><span>管理人员基本信息列表</span></div>
    <div class="div_titleoper">
        <input type="checkbox" id="top_ch_checkall"/> 全选
        <a href="admin/admin_add.jsp"><img src="images/add.gif"/>添加 </a>
        <a onclick="return confirm('确定要删除吗')" id="duoxuan"><img src="images/del.gif"/>删除</a> </div>
</div>

<form action="xxx"  name="form1">

    <table class="main_table" >
        <tr>
            <th><input type="checkbox" id="ch_checkall" /></th>	<th>账号</th> 	<th>状态</th>	<th>备注</th>  <th>最后更新日期</th> 	<th>操作</th>
        </tr>
        <c:forEach var="c" items="${adminList}">
        <tr>
            <td>
                <input type="checkbox" name="ck_id" id="${c.id}" />
            </td>
            <td>${c.adminName}</td>
            <td name="st">${c.getstatename()}</td>
            <td> <a title=${c.note}>${c.shtext()}</a> </td>
            <td><fmt:formatDate value="${c.editDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
            <td>
                <c:choose>
                    <c:when test="${c.getstatename()=='锁定'}">
                            <a href="AdminServlet?flag=jie&id=${c.id}&pageIndex=${page.pageIndex}">解锁</a>
                    </c:when>
                    <c:when test="${c.getstatename()=='正常'}">
                            <a href="AdminServlet?flag=suo&id=${c.id}&pageIndex=${page.pageIndex}">锁定</a> |
                            <a href="AdminServlet?flag=update&id=${c.id}&pageIndex=${page.pageIndex}&adminName=${c.adminName}&note=${c.note}">修改</a> |
                            <a href="AdminServlet?flag=delet&id=${c.id}&pageIndex=${page.pageIndex}" onclick="return confirm('确定要删除吗')">删除</a>
                    </c:when>
                    <c:when test="${c.getstatename()=='删除'}">

                    </c:when>
                </c:choose>
            </td>
        </tr>
        </c:forEach>
    </table>
</form>

<div class="div_page" >
    <div class="div_page_left">
        共有 <label>${page.rowCount }</label> 条记录，
        当前第 <label>${page.pageIndex}</label> 页，
        共 <label>${page.pageCount }</label> 页
    </div>
    <div class="div_page_right" >
        <c:choose>
            <c:when test="${page.hasPre }">
                <button id="but1">首页</button>
                <button id="but2"> 上一页</button>
            </c:when>
            <c:otherwise>
                首页
                上一页
            </c:otherwise>
        </c:choose>

        <c:choose>
            <c:when test="${page.hasNext }">
                <button id="but3">下一页 </button>
                <button id="but4">尾页</button>
            </c:when>
            <c:otherwise>
                下一页
                尾页
            </c:otherwise>
        </c:choose>
        <button id="but5">转到</button>
        <input type="text" name="pageIndex" id="pageIndex" value="1" /> 页

    </div>

</div>
</body>
</html>
